package com.mljr.example.base;

import com.ctakit.sdk.app.base.MyActivity;
import com.mljr.example.BuildConfig;
import com.mljr.example.service.SystemService;

public class Config {

    // 开机引导版本
    public static int guide_version = 5;

    public static String[] choiceItemsTitle = new String[]{"测试", "开发", "本地", "演示", "线上"};


    /**
     * This class may not be instantiated
     */

    private Config() {
    }

    public static void reset() {
        Server.BASEURL = null;
        Server.H5_URL = null;
        Server.IMGURL = null;

    }

    public static class Server {

        // 上传图片
        public static String BASEURL = null;
        public static String H5_URL = null;
        public static String IMGURL = null;

        public static boolean online = true; // 线上


        /**
         * This class may not be instantiated
         */
        private Server() {
        }



        public static String getBaseUrl() {
            if (BASEURL == null) {
                if (online || !BuildConfig.DEBUG) {
                    BASEURL = "http://101.201.170.182:81";
                } else {
                    switch (Global.getDevModel()) {
                        case 0:// 测试模式
                            BASEURL = "http://meili-coolcard-consumer-test.obaymax.com";
                            break;
                        case 1:// 开发模式
                            BASEURL = "http://meili-coolcard-consumer-dev.obaymax.com";
                            break;
                        case 2:// 本地模式（暂时用 开发地址）
                            BASEURL = "http://meili-coolcard-consumer-dev.obaymax.com";
                            break;
                        case 3:// 演示模式
//
                            BASEURL = "http://123.57.57.225:10001";
                            break;
                        case 4:// Online
                            BASEURL = "http://101.201.170.182:81";
                            break;
                        default:// 线上
                            BASEURL = "http://101.201.170.182:81";
                            break;
                    }
                }
            }

            return BASEURL;
        }

        public static String getBaseH5Url() {
            if (H5_URL == null) {
                if (online || !BuildConfig.DEBUG) {
                    H5_URL = "http://www.51kuka.com/";
                } else {
                    H5_URL = "http://meili-coolcard-consumer-fe-test.obaymax.com/";
                    switch (Global.getDevModel()) {
                        case 0:// 测试模式
                            H5_URL = "http://meili-coolcard-consumer-fe-test.obaymax.com/";
                            break;
                        case 1:// 开发模式
                            H5_URL = "http://meili-coolcard-consumer-fe-dev.obaymax.com/";
                            break;
                        case 2:// 开发模式
                            H5_URL = Global.getLoalApi();
                            break;
                        case 3:// 演示模式
                            H5_URL = "http://staging-consumer.51kuka.com/";
                            break;
                        case 4:// Online
                            H5_URL = "http://www.51kuka.com/";
                            break;
                        default:// 线上
                            H5_URL = "http://www.51kuka.com/";
                            break;
                    }
                }
            }
            return H5_URL;
        }



        //"开发182", "开发150", "本地", "172", "线上"
        public static String getTitle(int devMode, String title) {

            if (!online && BuildConfig.DEBUG) {

                if (devMode < choiceItemsTitle.length) {
                    title = choiceItemsTitle[devMode] + "-" + title;
                }
            }

            return title;
        }




        public static void updateDevModel(MyActivity myActivity, int model) {
            try {
                Global.setDevModel(model);
                SystemService.clearData(false);
            } catch (Exception e) {
                // TODO: handle exception
            }
            if (myActivity != null) {
                myActivity.showToastMsg("重新登录");
            }

        }

    }

    public static class Preferences {

        public static final String RESERVED_PREFERENCE_DEVICE = "RESERVED_PREFERENCE_DEVICE";
        public static String UUID = "uuid";
        public static String TOKEN = "token";
        public static String USERID = "userId";
        public static String ISFIRST = "isFirst_" + Config.guide_version;

        public static String DEVMODEL = "devModel";
        public static String LOCALIP = "LocalIp";
        public static String LOGINSTATUS = "loginstatus";
        public static String PUSH_TOKEN = "push_token";
        public static String UCODE = "ucode";
        public static String MQTT_STATE = "mqtt_state";
        public static String USERNAME = "username";
        public static String SERVICEPHONE = "servicePhone";
        public static String MACADDRESS = "macAddress";
        public static String PASSWORD = "password";
        public static String NEWVERSION = "app_newVersion";
        public static String LAST_LOGIN_TIME = "last_login_time";
        public static String LAST_GETCAPTCHA_TIME = "last_getcaptcha_time";

        public static String LOANMSGNUM = "loanMsgNum";
        public static String DING_DEFAULT_VALUE = "ding_default_value";
        public static String MONT_DEFAULT_VALUE = "month_default_value";
        public static String LauncherBundle_TIME = "LauncherBundle_time";
        public static String DISCOVER_LIST_TIME = "discoverItemList_time";
        public static String DISCOVER_LIST = "discoverItemList_1";
        public static String CHOICE_MODEL = "choice_model";
        public static String AccessToken = "AccessToken";

        /**
         * This class may not be instantiated
         */
        private Preferences() {
        }

    }


}